<#assign base=request.contextPath />
<!DOCTYPE html>
<div class="row">
	<div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
			<div class="x_title">
				<h2>项目编辑 <small></small></h2>
				<div class="clearfix"></div>
			</div>
			<div class="x_content">
				<br/>
					<form id="postForm" data-parsley-validate class="form-horizontal form-label-left" method="post" action="${base}/gx/project/save">
				
					<input type="hidden" id="id" name="id" value="${((obj.id)?c)!0 }">
		            <input type="hidden" name="createTime" value="${(obj.createTime)!.now?string['yyyy-MM-dd HH:mm:ss']}">
		            <input type="hidden" name="updateTime" value="${.now?string['yyyy-MM-dd HH:mm:ss']}">
		         	<input type="hidden" name="isChecked" value="${(obj.isChecked)!0 }">
		            <input type="hidden" name="creator" value="${(obj.creator)!admin.userName}">
		            <input type="hidden" name="updator" value="${(obj.updator)!admin.userName}">
		             <input type="hidden" name="isDelete" value="${((obj.isDelete)?c)!0 }">
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12">
							美景标题
							<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="projectName" name="projectName" value="${(obj.projectName)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">
							项目封面图 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                       
                     		<input type="file" id="icon_dropify" name="file" class="dropify" data-default-file="${imagePath}${(obj.projectIcon)!''}">
                    		<input type="hidden" name="projectIcon" id="projectIcon" value="${(obj.projectIcon)!''}">
                            <input type="hidden" name="projectIconOld" id="projectIconOld" value="${(obj.projectIcon)!''}">
                        </div>
					</div>
			
						<label class="control-label col-md-3 col-sm-3 col-xs-12 " id="meijing" for="first-name ">
							美景大图： <span class="required">*</span>
                        </label>
					<div class="img-box full">
					
						<section class=" img-section">
							<div class="z_photo upimg-div clear" >
									 <section  class="z_file fl section">
										<img src="${base}/static/images/a11.png" class="add-img">
										<input type="file" name="file1"  id="file1" class="file1" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple />
									 <input type="hidden" images="${(obj.projectImages)!''}" imagePath="${imagePath}" name="projectImages" id="projectImages">
									 </section>
							 </div>
						</section>
					</div>
					<aside class="mask works-mask">
						<div class="mask-content">
							<p class="del-p ">您确定要删除作品图片吗？</p>
							<p class="check-p"><span class="del-com wsdel-ok">确定</span><span class="wsdel-no">取消</span></p>
						</div>
					</aside>

					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">项目内容 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<div class="summernote" id="content_summernote">
                                   ${(obj.projectContent)!''}       
                        	</div>
                        	
                        </div>
					</div>
			
					<div class="ln_solid"></div>
					<div class="form-group">
						<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
							<button type="button" class="btn btn-success" id="submit">保存</button>
							<button type="button" class="btn btn-primary" id="goBack">返回</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
 <script src="${base}/static/vendors/someupload/imgUp.js"></script>
<script type="text/javascript">
var base='${base}';
		var imgs=$(".upload-ul .diyControl img")
		console.log(imgs)
	 var idmsg='';
			
$(function() {
  showimgsbacj()
	//select2
	$(".select2").select2({width: "100%"});
	$('.summernote').summernote({
        height: 350, // set editor height
        minHeight: null, // set minimum height of editor
        maxHeight: null, // set maximum height of editor
        focus: false, // set focus to editable area after initializing summernote
        lang: 'zh-CN',
        shortcuts:false //禁止使用快捷键
    });
    // 封面上传
	 $('.dropify').dropify({
     	messages: {
		        'default': '点击或拖拽文件到这里',
		        'replace': '点击或拖拽文件到这里来替换文件',
		        'remove':  '移除文件',
		        'error':   '对不起，你上传的文件太大了',
		    }
     });
     // Used events
     drEvent = $('#icon_dropify').dropify();
     drEvent.on('dropify.afterClear', function(event, element) {
     	$("#infoIcon").val("");
     });
     		     //多图上传
					var $tgaUpload1 = $('#goodsUpload').diyUpload({
					    url: '${base}/gx/project/save',
					    success: function(data) {},
					    error: function(err) {},
					    buttonText: '',
					    accept: {
					        title: "Images",
					        extensions: 'gif,jpg,jpeg,bmp,png'
					    },
					    thumb: {
					        width: 120,
					        height: 90,
					        quality: 100,
					        allowMagnify: true,
					        crop: true,
					        type: "image/jpeg"
					    }
					});

     drEvent.on('dropify.errors', function(event, element) {
         console.log('Has Errors');
     });

	$("#goBack").click(function() {
		$("#main_content").load('${base}/gx/project/list');	        
    });
	
	$("#submit").click(function() {
		var projectName = $.trim($("#projectName").val());
 	if(projectName==""){
    		swal("请输入项目名称");
            return;
    	}

    	//获取数据
		drEvent = $('.dropify').dropify();
	    drEvent=drEvent.data('dropify')
	    if((drEvent.file.object !=null )){
	    	var projectIcon = drEvent.callBackBase64;
	    	projectIcon = projectIcon.substring(projectIcon.indexOf("base64")+7);
	    	$("#projectIcon").val(projectIcon);
	    }else{
	    	if($("#projectIcon").val()==""){
	    		swal("请上传资讯封面图");
	            return;
	    	}
	    }
	    
    	var markupStr = $('#content_summernote').summernote('code');
		$("#projectContent").val(markupStr);
		var projectContent = $.trim($("#projectContent").val());
    //    var url = "${base}/gx/project/save";
     //   $.post(url, $("#postForm").serialize(), function(data) {
      //      if (data.flag) {
       //     	swal(data.msg, "", "success");
         //       $("#main_content").load('${base}/gx/project/list');
          // }else{
         //  	swal(data.msg, "", "error");
        //   }
      // });
          uploadimg();//启用此方法
        $("#postForm").ajaxSubmit(function(data) {
    	 	if (data.flag) {
    	 		swal(data.msg, "", "success");
				$("#main_content").load('${base}/gx/project/list');
    	 	} 
    	 	else {
    	 		swal(data.msg, "", "error");
    	 	}
    	});
	});
});			    
</script>